using UnityEngine;

public class SkeletonStunnedState : EnemyState
{
    private new Skeleton Enemy => (Skeleton)base.Enemy;

    public SkeletonStunnedState(Enemy enemy, string animName) : base(enemy, animName) { }

    public override void Enter()
    {
        base.Enter();
        if (Enemy.CounterImage.activeSelf)
        {
            Enemy.CloseCounterAttackWindow();
        }
        Enemy.Fx.InvokeRepeating("RedColorBlink", 0, 0.1f);
        stateTimer = Enemy.stunnedDuration;
        Rb.velocity = new Vector2(-Enemy.FacingDirection * Enemy.stunnedDirection.x, Enemy.stunnedDirection.y);
    }

    public override void Update()
    {
        base.Update();
        if (stateTimer <= 0)
        {
            Enemy.SetVelocityToZero();
            StateMachine.ChangeTo(Enemy.IdleState);
        }
    }

    public override void Exit()
    {
        base.Exit();
        //enemy.hitFX.CancelColorChange();
        Enemy.Fx.Invoke("CancelColorChange", 0);
    }
}
